package com.z1.core.data.export.pdf.model;

import java.util.ArrayList;
import java.util.List;

public class PdfTable implements java.io.Serializable {

	private static final long serialVersionUID = 2930331134385368883L;
	
	//表格表头
	private PdfTableRow head = null;
	//表格内容
	private List<PdfTableRow> rows = null;
	
	public PdfTableRow getHead() {
		return head;
	}
	public void setHead(PdfTableRow head) {
		this.head = head;
	}
	public PdfTable headRow(PdfTableRow head) {
		this.setHead(head);
		return this;
	}
	public float[] getWidths() {
		float[] widths = new float[head.getCells().size()];
		int i = 0;
		for (PdfTableCell cell : head.getCells()) {
			widths[i++] = cell.getWidth();
		}
		return widths;
	}
	
	public List<PdfTableRow> getRows() {
		return rows;
	}
	public void setRows(List<PdfTableRow> rows) {
		this.rows = rows;
	}
	public void addRow(PdfTableRow row) {
		if (null == rows) {
			this.rows = new ArrayList<PdfTableRow>();
		}
		this.rows.add(row);
	}
	public PdfTable rows(List<PdfTableRow> rows) {
		this.setRows(rows);
		return this;
	}
	public PdfTable row(PdfTableRow row) {
		this.addRow(row);
		return this;
	}
	
}
